<?php

/**
* Gavick Image Slide I
* @package Joomla!
* @Copyright (C) 2009 Gavick.com
* @ All rights reserved
* @ Joomla! is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.0.0 $
**/

// access restriction
defined('_JEXEC') or die('Restricted access');
// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../../../components/com_virtuemart/virtuemart_parser.php' )) {
	require_once( dirname(__FILE__).'/../../../../components/com_virtuemart/virtuemart_parser.php' );
} else {
	require_once( dirname(__FILE__).'/../../../../components/com_virtuemart/virtuemart_parser.php' );
}

require_once('gk_ps_product.php');
$ps_product = new gk_ps_product;

// vars
$highest_layer = 0;
// initializing variables
$URI = JURI::getInstance();

if (!function_exists('htmlspecialchars_decode')) {
	function htmlspecialchars_decode($str, $options="") {
	    $trans = get_html_translation_table(HTML_SPECIALCHARS, $options);
	    $decode = ARRAY();
	    foreach ($trans AS $char=>$entity) { $decode[$entity] = $char; }
	    $str = strtr($str, $decode);
	    return $str;
 	}
}

?>

<div id="gk_is-<?php echo $this->ID;?>" class="gk_is_wrapper gk_is_wrapper-template clearfix">

	<div class="gk_is_preloader"><span>LOADING</span></div>
	
	<div class="gk_is_image" style="width:auto;height:<?php echo $this->settings["image_y"] + 2;?>px;">
		<?php for($i = 0; $i < count($this->slides); $i++) : ?>
			<?php if($i % $this->config['slides_amount'] == 0 ): ?>
			<div class="gk_is_slide_group">
			<?php endif; ?>
			
				<?php 
					// cleaning variables
					unset($path);
					// creating slide path
					$path = $URI->root().'components/com_gk3_photoslide/thumbs_big/'.$this->slides[$i]["filename"];
				?>
			
				<span class="gk_is_slide" style="margin-left:<?php echo $this->config["slide_margin"];?>px;" title=""><?php echo $path; ?></span>
				<div class="gk_is_slide_content gk_unvisible"><div><?php $ps_product->show_snapshot(str_replace('vm:PRODUCT=','',$this->slides[$i]['link']), true, true); ?><span class="gk_is_pointer"></span></div></div>
			<?php if($i % $this->config['slides_amount'] == $this->config['slides_amount'] - 1): ?>
			</div>
			<?php endif; ?>
		<?php endfor; ?>
		
		<?php if((count($this->slides) - 1) % $this->config['slides_amount'] != $this->config['slides_amount'] - 1): ?>
		</div>
		<?php endif; ?>
	</div>
	
	<?php if($this->config["interface"] == 'true') : ?>
	<div class="gk_is_pagination">
		<?php for($i = 0; $i < ceil(count($this->slides) / $this->config['slides_amount']); $i++) : ?>
		<span><?php echo $i+1; ?></span>
		<?php endfor; ?>
	</div>
	<?php endif; ?>
	
	<?php if($this->config['tooltips'] == 'true') : ?><div class="gk_is_tooltip gk_unvisible"></div><?php endif; ?>
</div>